# 脚本的button组件
from .ScriptWidget import ScriptWidget
from PySide6.QtWidgets import QPushButton


class ScriptButton(QPushButton):
    def __init__(self, parent: ScriptWidget, title, onClick=None):
        super(ScriptButton, self).__init__(parent)

        self.setText(title)
        self.setFixedSize(len(title) * (self.font().pointSize() + 7), parent.lineHeight)
        if onClick is not None:
            self.clicked.connect(onClick)

    def setPos(self, x, y):
        self.setGeometry(x, y, self.width(), self.height())
